<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Suspend</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>Suspend</h1>

<p>Disables or enables all or selected <a href="../Hotkeys.htm">hotkeys</a> and <a href="../Hotstrings.htm">hotstrings</a>.</p>

<pre class="Syntax">Suspend [, Mode]</pre>
<h3>Parameters</h3>
<dl>

  <dt>Mode</dt>
  <dd><p><strong>On</strong>: Suspends all <a href="../Hotkeys.htm">hotkeys</a> and <a href="../Hotstrings.htm">hotstrings</a> except those explained the Remarks section.</p>
      <p><strong>Off</strong>: Re-enables the hotkeys and hotstrings that were disable above.</p>
      <p><strong>Toggle</strong> (default): Changes to the opposite of its previous state (On or Off).</p>
    <p><strong>Permit</strong>: Does nothing except mark the current subroutine as being exempt from suspension.</p></dd>

</dl>

<h3>Remarks</h3>
<p>Any hotkey/hotstring subroutine whose very first line is Suspend (except <code>Suspend On</code>) will be exempt from suspension. In other words, the hotkey will remain enabled even while suspension is ON. This allows  suspension to be turned off via such a hotkey.</p>
<p>To disable selected hotkeys or hotstrings automatically based on the type of window that is present, use <a href="_IfWinActive.htm">#IfWinActive/Exist</a>.</p>
<p>Suspending a script's hotkeys does not stop the script's already-running <a href="../misc/Threads.htm">threads</a> (if any); use <a href="Pause.htm">Pause</a> to do that.</p>
<p>When a script's hotkeys are suspended, its tray icon changes to the letter S. This can be avoided by freezing the icon, which is done by specifying 1 for the last parameter of the Menu command. For example:</p>
<pre><a href="Menu.htm">Menu</a>, Tray, Icon, C:\My Icon.ico, , 1</pre>
<p>The built-in variable A_IsSuspended contains 1 if the script is suspended and 0 otherwise.</p>
<h3>Related</h3>
<p><a href="_IfWinActive.htm">#IfWinActive/Exist</a>, <a href="Pause.htm">Pause</a>, <a href="Menu.htm">Menu</a>, <a href="ExitApp.htm">ExitApp</a></p>
<h3>Example</h3>
<pre class="NoIndent">^!s::Suspend  <em>; Assign the toggle-suspend function to a hotkey.</em></pre>

<pre id="PostMessage" class="NoIndent"><em>; Send a Suspend command to another script.</em>
<a href="DetectHiddenWindows.htm">DetectHiddenWindows</a>, On
WM_COMMAND := 0x111
ID_FILE_SUSPEND := 65404
<a href="PostMessage.htm">PostMessage</a>, WM_COMMAND, ID_FILE_SUSPEND,,, C:\YourScript.ahk ahk_class AutoHotkey</pre>

</body>
</html>
